package diaporama;

//import java.awt.BorderLayout;
//import java.awt.Color;
//import java.awt.Graphics;
//import java.awt.Image;
import java.util.ArrayList;
//import javax.swing.ImageIcon;
//import javax.swing.JFrame;
//import javax.swing.JLabel;
//import javax.swing.JPanel;

@SuppressWarnings("serial")
public class DiapoThread implements Runnable {

	//Image[] images = null;
//	int iframe = 0;
	Thread thread;
//	JFrame frame = null;
//	JPanel panel = null;
//	JLabel lab = null;
	ArrayList<String> toto = null;

	public void init() {
		RechercheFichier file = new RechercheFichier();
		file.RechercheFichierFileOrDirectory();
		toto = file.getFileList();
	}

	public void start() {
		(thread = new Thread(this)).start();
	}

	public void stop() {
//		frame.dispose();
		thread = null;
	}

//	public void paint(Graphics g) {
//		Image current = getToolkit().getImage(toto.get(iframe));
//		g.drawImage(current, 0, 0, this);
//	}

	// a voir commetn redimmensionner une image
	// a voir pourquoi certaine image saute
	//
	public void run() {
		this.init();
		new DiaporamaView(toto);
//		long delay = 2000L;
//		this.init();// 1 seconde
//		frame = new JFrame();
//		panel = new JPanel();
//		frame.setTitle("Diaporama");
//		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//		frame.setLayout(new BorderLayout());
//		frame.add(panel, BorderLayout.CENTER);
//		// frame.setLayout(new GridLayout(2, 1));
//		frame.setVisible(true);
//		panel.setBackground(Color.GRAY);
//		try {
//			while (iframe < toto.size()) {
//				frame.setSize(400, 450);
//				frame.setLocation(100, 200);
//				lab = new JLabel(new ImageIcon(toto.get(iframe)));
//				panel.add(lab);
//				repaint();
//				Thread.sleep(delay);
//				panel.remove(lab);
//				panel.revalidate();
//				iframe++;
//				frame.pack();
//				// frame.repaint();
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
		this.stop();
	}
}
